var t = require("../../services/api.js");

Page({
    data: {
        tjLists: [],
        lists: [],
        types: [],
        homeBanner: [],
        count: 0,
        page: 1,
        empty: !1
    },
    goSearch: function() {
        wx.navigateTo({
            url: "/pages/search/index"
        });
    },
    onLoad: function(a) {
        var e = this;
        (0, t.getAdBanners)({
            position: "index"
        }).then(function(t) {
            200 === t.data.code && e.setData({
                homeBanner: t.data.data
            });
        });
    },
    getTjLists: function() {
        var a = this;
        (0, t.getGoods)({
            sort: "sales_2:desc"
        }).then(function(t) {
            200 === t.data.code && a.setData({
                tjLists: t.data.data.list
            });
        });
    },
    getGoodsType: function() {
        var a = this;
        (0, t.getGoodsType)().then(function(t) {
            200 === t.data.code && a.setData({
                types: t.data.data
            });
        });
    },
    getLists: function() {
        var a = this, e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 1;
        (0, t.getGoods)({
            page: e,
            pageSize: 8
        }).then(function(t) {
            200 === t.data.code && a.setData({
                lists: e > 1 ? [].concat(a.data.list, t.data.data.list) : t.data.data.list,
                count: t.data.data.count,
                page: e,
                empty: !(t.data.data.list.length > 0)
            });
        });
    },
    onReady: function() {},
    onShow: function() {
        this.getTjLists(), this.getLists(), this.getGoodsType();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        wx.stopPullDownRefresh(), this.onShow();
    },
    onReachBottom: function() {
        var t = this.selectComponent("#pagination");
        if (!t) return !1;
        var a = t.hasMore();
        a && this.getLists(a);
    },
    onShareAppMessage: function() {
        return {
            path: "/pages/index/index",
            imageUrl: "/images/shareo.jpg",
            title: "免费的外卖才更”香“"
        };
    }
});